package com.lgh.hotel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lgh.hotel.dao.mapper.RoomGuestServerDao;
import com.lgh.hotel.dao.pojo.GuestServer;
import com.lgh.hotel.service.RoomServerServer;
import com.lgh.hotel.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomServerServiceImpl implements RoomServerServer {
    @Autowired
    RoomGuestServerDao guestServerDao;


    @Override
    public Result tempToUser() {
        return null;
    }

    @Override
    public Result select(GuestServer params) {
        LambdaQueryWrapper<GuestServer> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(null != params.getUserId(), GuestServer::getUserId, params.getUserId()).orderByDesc(GuestServer::getId);
        List<GuestServer> tables = guestServerDao.selectList(queryWrapper);
        return Result.succ(tables);
    }

    @Override
    public void insert(GuestServer params) {
        guestServerDao.insert(params);
    }

    @Override
    public void update(GuestServer params) {
        guestServerDao.updateById(params);
    }

    @Override
    public void delete(GuestServer params) {
        guestServerDao.deleteById(params.getId());
    }
}
